﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "AppGeneralCommandContext.h"
#include "ContextualPanel.h"

using namespace gdmp;

namespace Sample
{
    //  界面通用配置：长度类参数显示精度为2，因子类参数显示精度为2
    class AppUiGeneralConfig final :public IUiGeneralConfig {
    public:
        void GetLengthParameterDisplayPrecision(int& precision) const override {
            precision = 2;
        }

        void GetFactorParameterDisplayPrecision(int& precision) const override {
            precision = 2;
        }
    };

    // 通用编辑默认参数配置
    class AppGeneralEditCommandConfig final :public IEditGeneralCommandConfig {
    public:
        void GetScaleDefaultParameters(
            double& scaleFactor,
            bool& isNeedCopy) const override {
            scaleFactor = 1.0;
        }

        void GetOffsetDefaultParameters(
            bool& isFixedOffsetValue,
            double& offsetValue,
            bool& isNeedCopy
        ) const override {
            offsetValue = 1000.0;
        };

        void GetRectangleArrayDefaultParameters(
            unsigned& colCount,
            double& colDistance,
            unsigned& rowCount,
            double& rowDistance
        ) const override {
            colDistance = 1000.0;
            rowDistance = 1000.0;
        }

        void GetPathArrayDefaultParameters(
            bool& IsDivideOrMeasure,
            double& distance,
            unsigned& count
        ) const override {
            distance = 1000.0;
        }

        void GetChamferDefaultParameters(
            bool& isEqualDistance,
            double& firstLineCutLength,
            double& secondLineCutLength,
            bool& isTotal
        ) const override {
            firstLineCutLength = 1000.0;
            secondLineCutLength = 1000.0;
        }

        void GetFilletDefaultParameters(
            double& arcRadius,
            bool& isTotal
        ) const override {
            arcRadius = 1000.0;
        }
    };

    AppGeneralCommandContext::AppGeneralCommandContext()
    {
        m_opContextualPanel = NEW_AS_OWNER_PTR(ContextualPanel);
        m_opUiGeneralConfig = NEW_AS_OWNER_PTR(AppUiGeneralConfig);
        m_opEditGeneralCommandConfig = NEW_AS_OWNER_PTR(AppGeneralEditCommandConfig);
    }

    gdmp::IContextualPanel* AppGeneralCommandContext::GetContextualPanel()
    {
        return m_opContextualPanel.get();
    }

    const gdmp::IUiGeneralConfig* AppGeneralCommandContext::GetGeneralConfig() const
    {
        return m_opUiGeneralConfig.get();
    }

    const gdmp::IEditGeneralCommandConfig* AppGeneralCommandContext::GetConfig() const
    {
        return m_opEditGeneralCommandConfig.get();
    }

}
